<%@page import="org.springframework.security.core.context.SecurityContextHolder"%>
<%@page import="org.apache.commons.lang.StringUtils"%>
<%@page import="org.apache.commons.lang.time.DateFormatUtils"%>
<%@page import="org.springframework.util.CollectionUtils"%>
<%@page import="java.util.Collection"%>
<%@ include file="../common/common_include.jsp"%>
<%@ page language="java" contentType="text/html; charset=UTF-8"
	pageEncoding="UTF-8"%>


<%
	SoftForm form = (SoftForm)request.getAttribute("command");
	String isBJ = (String)request.getAttribute("isBJ");
	String isZBSoft = "";
	String isZJSoft = "";
	String isFJSoft = "";
	List<TblOaSoftType> fileTypeList =(List<TblOaSoftType>)request.getAttribute("fileTypeList");
	TblOaSoft soft = (TblOaSoft)request.getAttribute("soft");
	String userName = SecurityContextHolder.getContext().getAuthentication().getName();
	
	String nowDate = DateFormatUtils.format(new Date(), "yyyy-MM-dd HH:mm:ss");
	String fileType = soft.getTypeId()+"";
%>
			<div >
				<form id="noticeFORM" name="form" target="coreIframe"
					action="<%=request.getContextPath()%>/soft/doEdit" method="post" enctype="multipart/form-data">
					<div class="breadcrumb">
						<div class="bcIcon"></div>
						<ul class="bcNav">

							<li>编辑软件</li>
						</ul>
					</div>
<input type="hidden" name="id" value="<%=EncrypTool.encode(soft.getFileId()+"")%>">
					<table class="formTable">
						<tr>
							<td class="tdTitle">文件类型:</td>
							<td>
								<select name="typeId">
									<%
										if(!CollectionUtils.isEmpty(fileTypeList)){
											for(TblOaSoftType coreFileType: fileTypeList){
												String type = coreFileType.getTypeId()+"";
												String typeName = coreFileType.getFileType();
												%>
										    	<option value="<%=type%>" <%=fileType.equalsIgnoreCase(type)?"selected=selected":""%> ><%=typeName%></option>
												<%
											}
										}
									%>
								</select>
							</td>
						</tr>
						
						<tr>
							<td class="tdTitle">发布时间:</td>
							<td><input class="inputText xs" type="text"
								name="publicDate" checkNull="true" value="<%=nowDate %>"
								onClick="WdatePicker({dateFmt:'yyyy-MM-dd HH:mm:ss'})" /></td>
						</tr>
						<tr>
							<td class="tdTitle">发布人:</td>
							<td><input class="inputText xs" type="text" name="publicMan" checkNull="true" value="<%=soft.getPublicMan()%>"/></td>
						</tr>
						<tr>
							<td class="tdTitle">软件名称:</td>
							<td><input class="inputText xs" type="text" name="name" checkNull="true" placeholder="请输入软件名称" value="<%=soft.getFileName() %>" />
							<span class="errorTipWrap" id="errorTip_name">
							</td>
						</tr>
						<tr>
							<td class="tdTitle">文件:</td>
							<td>
								<!-- <input class="inputText xs" type="text" name="publicMan" checkNull="true"/> -->
								<sec:authorize ifAllGranted="ADD_SOFT">
									<input type="file" id="multipartFile">
									<span class="uploadResultLabel" id="uploadResultLabel" style="display: inline-block;"><%=soft.getDownfileName()%></span>
									<div>
										<span class="uploadTip">只能上传doc,docx,xls,xlsx,ppt,pptx,txt,pdf,zip,rar,jpg格式的文件</span>
									</div>
									<input type="hidden" name="tempFileId" value="">
								</sec:authorize>
							</td>
						</tr>
						<tr>
							<td class="tdTitle">软件描述：</td>
							<td class="" colspan="2">
								<div style="padding-top:10px;padding-bottom:10px;">
								<textarea id="content" name="desc" 
								style="width: 700px; height: 200px; visibility: hidden;"><%=soft.getFileDesc() %></textarea>
								</div>
								<span class="errorTipWrap" id="errorTip_desc">
							</td>
						</tr>
						
						<%if("1".equals(isBJ)){
							String isCenter = (String)request.getAttribute("isCenter");
							if("1".equals(isCenter)){
								isZBSoft = (String)request.getAttribute("isZBSoft");
								isZJSoft = (String)request.getAttribute("isZJSoft");
								isFJSoft = (String)request.getAttribute("isFJSoft");%>
							<tr id="recRegion">
								<td class="tdTitle">可见区域：</td>
								<td class="" colspan="2">
								<div class="checkbox-wrap">
										<label>
											<input type="checkbox" value="1" name="toZB" id="toZB" class="checkbox">
											<span>广东区</span><span>&nbsp;&nbsp;&nbsp;&nbsp;</span>							
										</label>
										<label>
											<input type="checkbox" value="1" name="toZJ" id="toZJ" class="checkbox">
											<span>浙江区</span><span>&nbsp;&nbsp;&nbsp;&nbsp;</span>
										</label>
										<label>
											<input type="checkbox" value="1" name="toFJ" id="toFJ" class="checkbox">
											<span>福建区</span>
										</label>
									</div>
								</td>
							</tr>
						<%	}
						} %>
						
						<tr>
							<td class="tdTitle"></td>
							<td>
								<div>
									<input class="input-btn-microsoft" type="submit" value="提交">
									<a class="a-btn-microsoft" href="javascript:XF.Soft.manageSoft()">取消</a>
								</div>
							</td>
						</tr>
						
					</table>
				</form>
			</div>
	<iframe name="coreIframe" style="display: none"></iframe>
	<div class="popContainer" id="popContainer" style="display: none;"></div>

<script type="text/javascript">

	$(function() {
		XF.createKindEditor("content");
		$("input[name=name]").focus();
		//XF.Soft.init();
		XF.uploadFile("multipartFile","<%=request.getSession().getId()%>");
		
		if('<%=isZBSoft %>'=="1"){
			$("#toZB").attr("checked",'true');
		}
		if('<%=isZJSoft %>'=="1"){
			$("#toZJ").attr("checked",'true');
		}
		if('<%=isFJSoft %>'=="1"){
			$("#toFJ").attr("checked",'true');
		}
	});
</script>